#!/bin/bash

function add_apt_key {
    wget http://apt.pearsoncomputing.net/public.gpg
    apt-key add public.gpg
}

function install_wget {
    echo "[+] Installing wget..."
    apt-get -y --force-yes install wget
    if [ -x /usr/bin/wget ] ; then
        echo "[+] Install complete (wget).."
    else
        echo "[-] Could not find wget, exiting.."
        exit 1
    fi
}

if  [ -x /usr/bin/wget ] ; then
    echo "[+] Adding gpg key for the kde3 mirror..."
    add_apt_key;
else
    install_wget;
    echo "[+] Adding gpg key for the kde3 mirror..."
    add_apt_key;
fi

cp -rv /tmp/sources.list /etc/apt/sources.list
echo "[+] Updating apt cache.."
apt-get update
echo "[+] Installing kubuntu desktop environment..."

#
# remove: ppp postfix network-manager network-manager-kde-kde3 network-manager-vpnc networkstatus-kde3 ktorrent-kde3 akregator-kde3 amarok-kde3 amarok-common-kde3 ark-kde3 bluez bluez-cups bluez-alsa bluez-gstreamer bluez-utils k3b-kde3 rdesktop kaffeine-kde3 kamera-kde3 k3b-data-kde3 karm-kde3 katapult-kde3 kcontrol-kde3 kcron-kde3 kdepim-wizards-kde3 kdesudo-kde3 kmail-kde3 kontact-kde3 konversation-kde3 kopete-kde3 kppp-kde3 krdc-kde3 kscreensaver-kde3 gksu jockey-gtk khelpcenter-kde3 kmag-kde3 knetworkconf-kde3
# add: kdebase-kde3 kwin-kde3 kdelibs-data-kde3 kdm-kde3 konqueror-kde3 konqueror-nsplugins-kde3 openoffice.org-kde3 openoffice.org-writer openoffice.org-calc openoffice.org-impress openoffice.org-common openoffice.org-math samba xserver-xorg
#

apt-get -y --force-yes install imagemagick konqueror-kde3 flashplugin-nonfree
apt-get -y --force-yes install kubuntu-desktop-kde3
apt-get --purge remove < /tmp/res/Removedebs.txt

echo "[+] Install complete, now starting on custom .deb files...."
dpkg -i /tmp/res/*.deb
apt-get -y --force-yes autoremove
apt-get -y --force-yes autoclean
